<?php

require_once dirname(dirname(dirname(__FILE__))).'/FileSystem.php';

class RL_Config_Storage_Fs implements ConfigStorage
{
	public function __construct ($config)
	{
		$this->factory = $config;
	} // end of __construct

	public function find ($key)
	{
		$parts = explode($this->factory->getPathSeparator(), $key);
		$fso   = makeFileSystemObject($this->getBase());
		$next = array_shift($parts);
		while ($next && $fso instanceof Dir) {
			$fso = $fso[$next];
			$next = array_shift($parts);
		}
		if ($fso instanceof File) {
			$self = array();
			$this->loadConfig($self, $fso->getPath());
			return $next ? $self[$next] : $self;
		}

	} // end of function find
	public function save ($key, $value)
	{
	
	} // end of function save
	public function getBase ()
	{
		return $this->path;
	} // end of function getBaseDir

	public function loadConfig (&$self, $path)
	{
		$ctx = $this->factory->ctx;
		include ($path);
	} // end of function loadConfig
}

